package com.rick.mr.numsort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


public class NumSortMapper extends Mapper<LongWritable, Text, IntWritable, NullWritable>{

    private final IntWritable numKey = new IntWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();
        numKey.set(Integer.parseInt(line));
        context.write(numKey, NullWritable.get());
    }
}

